import Vue from 'vue'
import VueRouter from 'vue-router'


Vue.use(VueRouter)
// 用户访问的url地址 和组件建立关联关系   login   login/index.vue   /home  home/index.vue
const routes = [
    {
        path: '/',
        redirect: '/login'   // 用户访问  /   重定向到   /login
    },
    {
        path: '/login',
        name: 'login',
        component: () => import('@/views/login/index.vue')
    },
    {
        path: '/register',
        name: 'register',
        component: () => import( '@/views/register/index.vue')
    },
    {
        path: '/home',
        redirect:'/home/user',
        name: 'home',
        component: () => import('@/views/home/index.vue'),
        children: [
            {
                path: 'user',
                name: 'user',
                component: () => import( '@/views/user/index.vue')
            },
            {
                path: 'student',
                name: 'student',
                component: () => import(/* webpackChunkName: "about" */ '@/views/student/index.vue')
            },
            {
                path: 'course',
                name: 'course',
                component: () => import(/* webpackChunkName: "about" */ '@/views/course/index.vue')
            }
        ]
    }
]

const router = new VueRouter({
    routes
})

export default router
